import 'package:battery/battery.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:ibooks/pages/index.dart';
import 'package:ibooks/service/system.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'const/constant.dart';

main() async {



  await initApp();
  runApp(IBookApp());
}

Battery _battery;

initApp() async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  SystemService service = new SystemService(prefs: prefs);
  _battery = Battery();
  _battery.onBatteryStateChanged.listen((BatteryState event) {
    if (BatteryState.charging == event) {
    }
  });
  int level = await _battery.batteryLevel;
  service.setInt(Constant.batteryLevel, level);
//  SpUtil.putInt(Constant.batteryLevel, level);

}

class IBookApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'iBooks',
      theme: ThemeData(
        primaryColor: Colors.white
      ),
      home: BookShelfPage(),
    );
  }
}
